﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Cryptography;

namespace SZHelperCore.CryptoHelpers
{
    public class SHA1CryptoUtil
    {
        public static string Encrypt(string plainTxt, Encoding encoding)
        {
            var plainBytes = encoding.GetBytes(plainTxt);
            return Encrypt(plainBytes);
        }
        public static string Encrypt(byte[] plainBytes)
        {
            using var sha1 = SHA1.Create();
            var hash = sha1.ComputeHash(plainBytes);
            return Convert.ToHexString(hash); // 自动大写十六进制，等价于 X2
        }
    }
}
